<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/a.js"></script>
    <script>
        function $(id) {
            return document.getElementById(id)
        }
        window.onload=function () {
            setLoginInfo();
            fullTable();
        }



        function setLoginInfo() {
            axios.get("/user/getLoginUser").then(resp=>{
                if (resp.data =='' ){
                    $("loginSpan").innerHTML="你好，请先<a href='/html/login.html'>登录</a>";
                }
                else {
                    $("loginDiv").style.visibility="visible";
                    $("loginU").innerHTML="登录用户"
                    $("loginImg").src="/html/img/"+resp.data.image
                    $("loginName").innerHTML=resp.data.name
                    $("loginEmail").innerHTML=resp.data.email
                }
            });
        }
        function fullTable() {
            axios.get("/channel/findAll").then(resp=>{
                var str="";
                resp.data.forEach(e=>{
                    str+=`<tr><td><a href="/html/mainPost.html?id=${e.id}">${e.name}</a></td><td>${e.info}</td><td>${e.num}</td></tr>`
                });
                $("channelContent").innerHTML=str;
            });
        }
    </script>
</head>
<body>
    <div style="background-color: skyblue">
        <a href="index.html">首页</a> |
        <a href="login.html">登录</a> |
        <a href="register.html">注册</a> |
        <a>退出</a> |
        <a>管理</a> |
        <a>风格</a>
    </div>
    <span>登录状态与统计</span><br>
    <span id="loginSpan"></span>
    <div id="loginDiv" style="visibility: hidden">
        <h5 id="loginU"></h5>
        <img src="" height="50px" width="50px" id="loginImg">
        用户名：<span id="loginName"></span><br>
        邮箱：<span id="loginEmail"></span>
    </div>
    <div>
        <table border="1" width="80%" cellspacing="0">
            <thead><tr><th>频道名称</th><th>频道描述</th><th>主贴数量</th></tr></thead>
            <tbody id="channelContent"></tbody>
        </table>
    </div>
    <a>=> 友情论坛</a>
</body>
</html>